package com.lonwin.inspectionmanagement.mvp.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.amap.api.services.geocoder.GeocodeSearch;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.lh.LhSmoothEarthSurfaceView;
import com.lh.features.LhCoordinate;
import com.lonwin.inspectionmanagement.R2;
import com.lonwin.inspectionmanagement.app.AppConstants;
import com.lonwin.inspectionmanagement.di.component.DaggerEditPointRecordComponent;
import com.lonwin.inspectionmanagement.mvp.contract.EditPointRecordContract;
import com.lonwin.inspectionmanagement.mvp.model.entity.bean.CreaQuestResultBean;
import com.lonwin.inspectionmanagement.mvp.model.entity.bean.ImageBean;
import com.lonwin.inspectionmanagement.mvp.model.entity.bean.PointHistoryBean;
import com.lonwin.inspectionmanagement.mvp.presenter.EditPointRecordPresenter;

import com.lonwin.inspectionmanagement.R;
import com.lonwin.inspectionmanagement.mvp.ui.adapter.OnePicAdapter;
import com.lonwin.inspectionmanagement.widget.voicerecorder.widget.VoiceRecorderView;


import java.util.List;

import butterknife.BindView;

import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 12/15/2018 21:21
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
public class EditPointRecordActivity extends BaseActivity<EditPointRecordPresenter> implements EditPointRecordContract.View {
    private CreaQuestResultBean.DataBean mDataBean;

    private final int REQUEST_CODE_CHOOSE=12034;
    List<Uri> mSelected;
    @BindView(R2.id.back_icon)
    ImageView backIcon;
    @BindView(R2.id.toolbar_back)
    RelativeLayout toolbarBack;
    @BindView(R2.id.toolbar_title)
    TextView toolbarTitle;
    @BindView(R2.id.toolbar)
    Toolbar toolbar;
    @BindView(R2.id.creaPointRecord_LhEarthSurfaceView)
    LhSmoothEarthSurfaceView creaPointRecordLhEarthSurfaceView;

    @BindView(R2.id.creaPointRecord_address)
    EditText creaPointRecordAddress;
    @BindView(R2.id.creaPointRecord_type)
    TextView creaPointRecordType;
    @BindView(R2.id.creaPointRecord_descript)
    EditText creaPointRecordDescript;
    @BindView(R2.id.creaPointRecord_RecyclerView)
    RecyclerView creaPointRecordRecyclerView;
    @BindView(R2.id.creaPointRecord_record_lay)
    LinearLayout creaPointRecordrecordlay;
    @BindView(R2.id.voice_recorder)
    VoiceRecorderView voiceRecorderView;

    @BindView(R2.id.creaPointRecord_record_save)
    TextView saveToUpload;

    @BindView(R2.id.creaPointRecord_lay_hh)
    LinearLayout creaPointRecord_lay_hh;

    @BindView(R2.id.creaPointRecord_hh)
    TextView creaPointRecord_hh;

    @BindView(R2.id.creaPointRecord_latLont)
    TextView creaPointRecord_latLont;


    OnePicAdapter picAdapter;
    private GeocodeSearch geocodeSearch;
    private ImageBean selectedImageBean;
    private String autioPath;
    private PointHistoryBean.DataBean dataBean;
    private LhCoordinate mlhCoordinate;
    private int voiceTime=0;
    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerEditPointRecordComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_edit_point_record; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mDataBean= (CreaQuestResultBean.DataBean) getIntent().getSerializableExtra(AppConstants.EXTRA_DATA);
        if (mDataBean==null){
            finish();
        }

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    void updateView(){
        creaPointRecordAddress.setText(mDataBean.getAddr());

    }
}
